<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数组拆分</title>
</head>
<body>
  <script>
    function fn(nums) {
      let ans = 0;
      nums.sort((a, b) => a - b);
      for (let i = 0; i < nums.length; i += 2) {
        ans += nums[i];
      }
      return ans;
    }
    console.log(fn([1,4,3,2]))
  </script>
</body>
</html>